<template>
	<div class="front">
		<div class="table bj">
			<el-scrollbar style="height: 100%;">
                <el-table :data="tableData" border ref="table" highlight-current-row @row-click="rowClick" style="width: 100%">
                    <el-table-column label="类别代码" type="index" width="289" :index="indexMethod" align="center"></el-table-column>
                    <el-table-column property="name" label="类别名称" width="290" align="center"></el-table-column>
                </el-table>
            </el-scrollbar>
		</div>
		<div class="widgets bg-white">
            <div class="btn-group right">
                <el-button type="primary" v-if="isCheckBetweenObject[0]" @click="add">增加</el-button>
                <el-button type="primary" v-else disabled>增加</el-button>
                <el-button type="warning" @click="del">删除</el-button>
                <el-button type="success">保存</el-button>
                <el-button type="danger" @click="close">关闭</el-button>
            </div>
        </div>
	</div>
</template>
<script>
export default {
	data() {
		return {
			tableData: this.$store.state.accountSubjectStore.betweenObject,
			isCheckBetweenObject: this.$store.state.accountSubjectStore.isCheckBetweenObject,
			currentRow: {},		//临时存储选中的核算项目
		}
	},
	methods: {
		rowClick(row) {		//单击
			this.currentRow = row;
		},
		indexMethod(index) {
			return '00' + (index + 1);
		},
		add() {			//新增核算类别
			this.$util.openLayerIframe({title: '选择核算项目类别', zIndex: 13, width: '600px', height: '480px', url: this.$domain + '/#/basicData/accountSubject/tab/selectType'});
		},
		del() {		//删除指定核算类别数据
			if(JSON.stringify(this.currentRow) === '{}') {
				this.$store.commit('accountSubjectStore/deleteBetweenObjectById');
			} else {
				this.$store.commit('accountSubjectStore/deleteBetweenObjectById', this.currentRow['id']);
			}
			this.currentRow = {};
		},
		close() {		//关闭弹窗
            let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
		}
	}
}
</script>
<style scoped>
	.table {padding: 0 10px;height: calc(100% - 54px);}
	.table, .widgets {min-width: auto;}
</style>